package com.li.reflect;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class Test3 {
    public static void main(String[] args) throws Exception{

        //获取类
        Class<?> clazz = Class.forName("com.li.reflect.SomeService");
        //获取方法
        Method doSome = clazz.getDeclaredMethod("doSome", String.class);
        //获取对象
        Constructor<?> constructor = clazz.getConstructor();
        Object someService = constructor.newInstance();
        //调用方法
        Object result = doSome.invoke(someService, "hello world");
        //打印返回值
        System.out.println(result);
    }
}
